package com.xspace.android.xafcommon.util;

import android.os.Environment;

import com.xspace.android.xafcommon.appliction.BaseApplication;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

public class AppConstant {
    /**
     * 推送新闻是否通知
     */
    public static final String newsNotify = "newsNotify";
    /**
     * 推送新闻是否通知
     */
    public static final String emsNotify = "emsNotify";

    public static final String ROBOTDATA = "robotdata";
    /**
     * 广播参数key
     */
    public static final String BR_KEY_CMD = "param";
    /**
     * 操作服务的广播
     */
    public static final String BR_SERVICE_HANDLE = "cn.xspace.mobile.ServiceHandlerBroadcastReceiver";

    /**
     * 开启服务
     */
    public static final String BR_SERVICE_HANDLE_VALUE_START = "start";

    /**
     * 关闭服务
     */
    public static final String BR_SERVICE_HANDLE_VALUE_STOP = "stop";

    /**
     * 信息刷新
     */
    public static final String BR_SERVICE_UPDATE = "cn.xspace.mobile.data.update";

    /**
     * 服务状态结果的广播
     */
    public static final String BR_SERVICE_STATUS = "cn.xspace.mobile.ServiceStatusBroadcastReceiver";

    /**
     * 好友状态变化广播
     */
    public static final String FRIEND_CHANGE_STATUS = "cn.xspace.mobile.friendStatusBroadcastReceiver";

    /**
     * 好友添加成功广播
     */
    public static final String FRIEND_ADD_STATUS = "cn.xspace.mobile.friendAddBroadcastReceiver";

    /**
     * 好友删除成功广播
     */
    public static final String FRIEND_DELETE_STATUS = "cn.xspace.mobile.friendDeleteBroadcastReceiver";

    /**
     * 已经开启服务
     */
    public static final String BR_SERVICE_STATUS_CONNECTED = "connected";

    /**
     * 已经关闭服务
     */
    public static final String BR_SERVICE_STATUS_DISCONNECTED = "disconnected";
    /**
     * 因为错误已经关闭服务
     */
    public static final String BR_SERVICE_STATUS_DISCONNECTED_ERROR = "disconnected_error";
    /**
     * 关闭原因
     */
    public static final String BR_SERVICE_STATUS_DISCONNECTED_REASON = "reason";

    public static final String PUBLIC_NUMBER = "12316";
    public static final String INTENT_PARAM_USER_ADDRESS = "param_user_address";
    public static final String INTENT_PARAM_USER_JID = "param_user_jid";
    public static final String INTENT_PARAM_USER_NAME = "param_user_name";
    public static final String INTENT_PARAM_INVITE_ADD_STAUS = "invite_add_status";
    public static final String INTENT_PARAM_USER_THREADID = "param_user_thread_id";
    public static final String INTENT_PARAM_USER_MESSAGE_CONTENT = "param_user_message_content";
    public static final String INTENT_PARAM_MESSAGE_TYPE = "param_message_type";
    public static final String INTENT_PARAM_FRIEND_TYPE = "param_friend_type";
    public static final String INTENT_PARAM_USER_CONTACT = "param_user_Contact";
    public static final String INTENT_PARAM_USER_HREAD = "param_user_hread";
    public static final String SERVER_INFO_USER_RESOURCE = "android";

    // preference const
    public static final String ACCOUNT_USERNAME_KEY = "account_username";
    public static final String ACCOUNT_PASSWORD_KEY = "account_password";
    /**
     * 1验证，其他未验证
     */
    public static final String ACCOUNT_VALIDATED = "ACCOUNT_VALIDATED";
    public static final String STATUS_BAR_REMINDER_NOT_OPEN = "status_bar_reminder";
    public static final String VOICE_REMINDER_NOT_OPEN = "voice_reminder";
    public static final String VIBRATION_REMINDER_NOT_OPEN = "vibration_reminder";

    /**
     * 应用SD卡位置
     */
    public static final String APP_DIR = Environment.getExternalStorageDirectory() + File.separator + "wnx";
    public static final String OLD_APP_DIR = Environment.getExternalStorageDirectory() + "/maf/";
    public static final String DATA = Environment.getDataDirectory().getPath();
    public static final String DB_PATH = DATA + DATA + File.separator + BaseApplication.mInstance.getPackageName() +
            "/databases";

    public static final String APP_DIR_NEW = Environment.getExternalStorageDirectory() + File.separator + "wnx";

    //离线表单
    public static final String OFFLINE_FORM = APP_DIR + File.separator + "html" + File.separator;
    public static final String OFFLINE_FORM_UNZIP = APP_DIR + File.separator + "html" + File.separator + "www";
    //图片
    public static final String IMAGE_ADDRESS = APP_DIR + File.separator + "img" + File.separator;
    //数据库地址
    public static final String DB_ADDRESS = APP_DIR + File.separator + "database" + File.separator;
    //已下载图片地址
    public static final String IMAGE_ADDRESS_DL = IMAGE_ADDRESS + "dl" + File.separator;
    //头像图片地址
    public static final String IMAGE_HEAD = IMAGE_ADDRESS + "head" + File.separator;
    //语音
    public static final String VOICE_ADDRESS = APP_DIR + File.separator + "voice" + File.separator;
    //已下载音频地址
    public static final String VOICE_ADDRESS_DL = VOICE_ADDRESS + "dl" + File.separator;
    //文件
    public static final String FILE_ADDRESS = APP_DIR + File.separator + "file" + File.separator;
    //临时文件
    public static final String TEMP_ADDRESS = APP_DIR + File.separator + "temp" + File.separator;
    //崩溃记录
    public static final String CRASH_FILE_ADDRESS = APP_DIR + File.separator + "crash" + File.separator;
    public static final String QR_CODE_PATH = APP_DIR + File.separator + "qrCode.png";
    //农技员
    public static final String QAC_ADDRESS = APP_DIR + File.separator + "qac" + File.separator;

    public static final String IMAGE_ADDRESS_UN = AppConstant.QAC_ADDRESS + "img/un/";
    public static final String VOICE_ADDRESS_UN = AppConstant.QAC_ADDRESS + "voice/un/";


    public static final String SUFFIX_IMAGE = ".jpg";
    public static final String SUFFIX_PNG = ".png";
    public static final String SUFFIX_VOICE = ".amr";
    public static final String SUFFIX_ZIP = ".zip";
    public static final String SUFFIX_APK = ".apk";

    public static String getFileName(String url) {
        int separatorIndex = url.lastIndexOf("/");
        String path = (separatorIndex < 0) ? url : url.substring(separatorIndex + 1, url.length());
        return path;
    }

    public static final String MIANYI_KEY = "mianyi";
    public static final String CHANDI_JIANYI_KEY = "cdjy";

    //视频监控模块
    public static final String MONITOR_VIEW = "ctnq.cn.com.spjk";
    public static final String MONITOR_VIEW_MAIN = "ctnq.cn.com.spjk.activity.VideoListAct";

    public static Map<String, ModuleEnum> moduleMap = new HashMap<>();

    static {
        moduleMap.put(ModuleEnum.MonitorView.getPackageName(), ModuleEnum.MonitorView);
    }

    public enum ModuleEnum {

        MonitorView("monitorView", MONITOR_VIEW, "视频监控");

        ModuleEnum(String key, String packageName, String plugInName) {
            this.key = key;
            this.packageName = packageName;
            this.plugInName = plugInName;
        }

        private String key = "";
        private String packageName = "";
        private String appVersion = "";
        private String plugInName = "";

        public String getKey() {
            return key;
        }

        public String getPackageName() {
            return packageName;
        }

//        public String getDownloadUrl() {
//            return downloadUrl;
//        }

        public String getAppVersion() {
            return appVersion;
        }

        public String getApkPath() {
            return APP_DIR + File.separator + key + SUFFIX_APK;
        }

        public String getPlugInName() {
            return plugInName;
        }
    }

}
